package model

import (
	"gorm.io/gorm"
	__ "grpc/basic/proto"
)

type Episode struct {
	gorm.Model
	VideoId    int    `gorm:"type:int" json:"videoId"`
	Season     string `gorm:"type:varchar(10)" json:"season"`     //季
	Collection string `gorm:"type:varchar(10)" json:"collection"` //集
	Watch      int    `gorm:"type:int" json:"watch"`              //观看时长
	Duration   int    `gorm:"type:int" json:"duration"`           //总时长
}

func (v *Episode) ListEpisode(db *gorm.DB) (list []*__.ListEpisode, err error) {
	err = db.Debug().Model(&Episode{}).Select("id,video_id,season,collection,watch,duration").
		Find(&list).Error
	return list, err
}

type Like struct {
	gorm.Model
	UserId  int    `gorm:"type:int" json:"userId"`
	VideoId int    `gorm:"type:int" json:"videoId"`
	Pid     int    `gorm:"type:int" json:"Pid"`
	Runt    string `gorm:"type:varchar(20)" json:"runt"`
}

func (l *Like) AddLike(db *gorm.DB) error {
	return db.Debug().Create(&l).Error
}
